Skip to content

proposal: add new CRD OpenStackClusterIdentity #2628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 5, 2025

Conversation

bnallapeta
Copy link
Contributor

This PR adds a proposal doc to work on the issue described in #2386

Signed-off-by: Bharath Nallapeta <bnallapeta@mirantis.com>
Copy link

netlify bot commented Jul 22, 2025

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit 4af2ff4
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-openstack/deploys/688c7d24fb347600089077a5
😎 Deploy Preview https://deploy-preview-2628--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 22, 2025
@k8s-ci-robot k8s-ci-robot requested review from EmilienM and mdbooth July 22, 2025 06:21
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 22, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @bnallapeta. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very much in favour of this. A few API-related notes inline.

The more I think about it, the more I'm convinced we should extend identityRef rather than adding an alternative with a fallback. I think the semantics and validation will be much clearer.

Incidentally, on the subject of validations I'd expect this to be validated with CEL. Lets not add anything new to the existing webhooks when it's not required. That's an implementation detail, though, so no need to add CEL expressions to this doc unless you really want to.

**Key Edge Cases:**
- Both references specified: Use `clusterIdentityRef`, log warning
- Identity deletion: Clusters show degraded status, don't fail
- Permission changes: Dynamic re-validation during reconciliation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What permissions are you referring to here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified in docs.

@bnallapeta
Copy link
Contributor Author

I'm very much in favour of this. A few API-related notes inline.

The more I think about it, the more I'm convinced we should extend identityRef rather than adding an alternative with a fallback. I think the semantics and validation will be much clearer.

Incidentally, on the subject of validations I'd expect this to be validated with CEL. Lets not add anything new to the existing webhooks when it's not required. That's an implementation detail, though, so no need to add CEL expressions to this doc unless you really want to.

yes, I considered both while thinking about this proposal. Let me put down my thoughts as simple pros vs cons:

new clusterIdentityRef
pros:
zero risk to existing APIs
validation becomes easier and cleaner
fallback designed to support both
migration would be easier
naming is in par with other providers - users feel familiar

cons:
dual fields for the same purpose - might be confusing to users
maintenance burden

extend current identityRef
pros:
users don't have to learn about a new field, less confusing
cleaner long-term API

cons:
higher migration risk
have to consider migration scenarios for testing

Kindly think this over and let me know.

@mdbooth
Copy link
Contributor

mdbooth commented Jul 29, 2025

cons: higher migration risk have to consider migration scenarios for testing

I don't follow this. Can you explain the additional risk?

For additional context I'm thinking something like this:

Current

This is the existing syntax. It is identical, with identical semantics. The absence of a type field means we default to Secret.

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackCluster
metadata:
  name: my-cluster
  namespace: team-a
spec:
  identityRef:
    name: fallback-secret
    cloudName: openstack

ClusterIdentity

Specifying a ClusterIdentity. Note the type field.

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackCluster
metadata:
  name: my-cluster
  namespace: team-a
spec:
  identityRef:
    type: ClusterIdentity
    name: production-openstack

Current with explicit type

This form uses the current Secret semantics explicitly.

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OpenStackCluster
metadata:
  name: my-cluster
  namespace: team-a
spec:
  identityRef:
    type: Secret
    name: fallback-secret
    cloudName: openstack

This is a common pattern in kubernetes APIs. It's not strictly a discriminated union because that typically discriminates on a single sub-field, but it's close enough without breaking backwards compatibility. This pattern has a number of advantages:

  • It is very easy to validate: the validation is limited in scope to a single struct (in this case identityRef).
  • It is easy to implement without breaking backwards compatibility.
  • It is easy to extend in the future.
  • It is unambiguous: only a single thing can be expressed.

Incidentally, an older version of the CAPO API actually had a type field, but we removed it because we only had a single type. Perhaps that was short-sighted, but it's easy enough to add back.

Another reason in favour of extending the existing struct is that it would propagate everywhere that the struct is used, including OpenStackMachine (and Server). We have had users relying on separate Machine credentials, and there's no reason to restrict which credential types they can use.

Signed-off-by: Bharath Nallapeta <bnallapeta@mirantis.com>
Signed-off-by: Bharath Nallapeta <bnallapeta@mirantis.com>
@mdbooth
Copy link
Contributor

mdbooth commented Aug 4, 2025

/lgtm

@lentzi90 @EmilienM Any thoughts? This is quite a big change, but I think it's a good one.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2025
Copy link
Contributor

@mandre mandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API looks good to me but I think the implementation details is lacking information on how this impacts operations involving ORC. If there is no impact, we should say it.

Copy link
Contributor

@lentzi90 lentzi90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lentzi90

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2025
@k8s-ci-robot k8s-ci-robot merged commit 7ab1409 into kubernetes-sigs:main Aug 5, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from Inbox to Done in CAPO Roadmap Aug 5, 2025
@mdbooth
Copy link
Contributor

mdbooth commented Aug 7, 2025

@mandre There's definitely an impact on ORC. ORC will need to implement this or something like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants